<?php
  define('IN_ECS', true);
  
  require_once('plugins/simple_html_dom.php');
  require_once('plugins/cls_json.php');
  
  $action  = isset($_REQUEST['act']) ? trim($_REQUEST['act']) : 'county_rate';
  
  if($action == county_rate){
      
      $html = file_get_html('http://www.fx168.com/');
      $tt = $html->find('div[id=I_Currency]',0);
      $t_table = $tt->find('table',0);
      $str = '<table width="100%" border="0" cellspacing="0" >';
      $r = array();
      $rowIndex = 0;
      foreach($t_table->find('tr') as $k=>$v){
          $i = 0;
          $row = array();
          $rowIndex++;
          ///if($rowIndex > 1 && $rowIndex%2==1){
              //$str .= '<tr style="background:#FF99FF;">';
          //}else{
              $str .= '<tr>';
          //}
          
         foreach($v->find('td') as $tdk=>$tdv){
              if($tdv->find('a',0)){
                   $row[$i] = iconv('gb2312', 'utf-8',$tdv->find('a',0)->innertext);
                   $str .= '<td>'.iconv('gb2312', 'utf-8',$tdv->find('a',0)->innertext).'</td>';
             }else{
                 $row[$i] = iconv('gb2312', 'utf-8',$tdv->innertext);
                 $str .= '<td>'.iconv('gb2312', 'utf-8',$tdv->innertext).'</td>';
             }
             $i++;
         }
         array_push($r, $row);
         $str .= '</tr>';
         if($rowIndex >= 9){
             break;
         }
     }
     
     $str .= '</table>';
     $str = str_replace('"','\'', $str);
     //print_r($r);
     //$json = new JSON;
     //echo $str;
     //$result = array('content'=>$str);
     //$result = json_encode($result);
     //exit($json->encode($result, true));
     exit('{"content":"'.$str.'"}');
  }
  
  
?>
